﻿#pragma once
#include "ZuiLib.h"
#include "LRefObject.h"

namespace ZuiLib {

class LAnimationManager :public LuaClass<ZAnimationManager>
{
public:
	static this_t* instance()
	{
		return ZuiLib::ZAnimationManager::Instance();
	}

	int loadAnimation(LuaFuncState& L)
	{
		return L.lreturn(pThis->LoadAnimation(L.arg(0).toString()));
	}

	int loadAnimationMem(LuaFuncState& L)
	{
		return L.lreturn(pThis->LoadAnimation((uint8_t*)L.arg(0).toString(), L.arg(0).objLen()));
	}

	int removeAnimation(LuaFuncState& L)
	{
		pThis->RemoveAnimation(L.arg(0).toString());
		return 0;
	}

	BEGIN_MAP_FUNC(LAnimationManager)
	DECLARE_FUNC(loadAnimation),
	DECLARE_FUNC(loadAnimationMem),
	DECLARE_FUNC(removeAnimation),
	END_MAP_FUNC
};



class LAnimationLayout :public LRefObject<ZAnimationLayout>
{
public:

	int applyAnimation(LuaFuncState& L)
	{
		return L.lreturn(pThis->ApplyAnimation(L.arg(0).toString()));
	}

	int startAnimation(LuaFuncState& L)
	{
		pThis->StartAnimation();
		return 0;
	}

	int stopAnimation(LuaFuncState& L)
	{
		pThis->StopAnimation();
		return 0;
	}

	int isReserve(LuaFuncState& L)
	{
		return L.lreturn(pThis->IsReserve());
	}

	int setReverse(LuaFuncState& L)
	{
		pThis->SetReverse(L.arg(0).toBool());
		return 0;
	}

	int setDuration(LuaFuncState& L)
	{
		pThis->SetDuration(L.arg(0).toUInt());
		return 0;
	}

	int setStep(LuaFuncState& L)
	{
		pThis->SetStep(L.arg(0).toUInt());
		return 0;
	}

	int setDelay(LuaFuncState& L)
	{
		pThis->SetDelay(L.arg(0).toUInt());
		return 0;
	}


	BEGIN_MAP_FUNC(LAnimationLayout)
	DECLARE_FUNC(applyAnimation),
	DECLARE_FUNC(startAnimation),
	DECLARE_FUNC(stopAnimation),
	DECLARE_FUNC(isReserve),
	DECLARE_FUNC(setReverse),
	DECLARE_FUNC(setDuration),
	DECLARE_FUNC(setStep),
	DECLARE_FUNC(setDelay),
	END_MAP_FUNC

	BEGIN_MAP_CONST
	DECLARE_CONST("STATE_START", ZuiLib::STATE_START),
	DECLARE_CONST("STATE_STOP", ZuiLib::STATE_STOP),
	END_MAP_CONST
};


}
